<template>
  <div class='container'>
    <div class='app-row m-20-t'>
      <span class="title bold width-100 align-right">商品名称:</span>
      <el-input class='flex-1' v-model="name_value"></el-input>
    </div>
    <div class="app-row j-c-c m-100-t">
      <el-button type="success" @click="add_button">添加拼团</el-button>
    </div>
    <el-dialog
      title="选择要拼团的商品"
      :visible.sync="choose_dialog"
      width="30%">
      <span slot="footer" class="dialog-footer">
        <el-button @click="choose_dialog = false">取 消</el-button>
        <el-button type="primary" @click="confirm_button">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import group_buying_request from "@/api/group_buying_request"
  export default {
    name: 'group_buying_add',
    data() {
      return {
        name_value: "",
        description_value: "",
        url_value: "",
        open_radio: "1",
        price_value: '',
        choose_dialog: false,
        setting_goods: false,
        text_value: '',
        rank_value: 0,
        people_value: '',
      }
    },
    created() {
  
    },
    mounted() {
  
    },
    methods: {
      add_button() {
        if (this.name_value == '') {
          this.$message.error("请输入拼团标题")
          return
        }
        if (this.people_value == '') {
          this.$message.error("请设置成团人数")
          return
        }
        if (this.people_value == '') {
          this.$message.error("请填写排序")
          return
        }
        let params = {
          title: this.name_value,
          goods_id: 696,
          limit_nums: this.people_value,
          sort: this.rank_value,
          // description: this.description_value,

        }
        group_buying_request.add_group_buying(params, res=> {
          this.$router.push('/marketing/group_buying')
        })
      },
      choose_goods() {
        this.choose_dialog = true
      },
      confirm_button() {
        this.choose_dialog = false
        this.setting_goods = true
      }

    }
  }
</script>

<style scoped>
@import "~@/styles/layout.scss";
</style>